home *** CD-ROM | disk | FTP | other *** search
/ Web Star/List Star - Eve…he Ultimate Internet Site / StarNine Internet Pubisher (Web Star and List Star)(StarNine)(1995).iso / ListSTAR™ / Tools and Enhancments / RFC Triggers / Check for Blank Subject RFC next >
Encoding:
Text File  |  1995-08-01  |  3.4 KB  |  82 lines  |  [TEXT/ToyS]

  1. -----------------------------------------------------------------------
  2. -- StarNine Technologies, Inc., hereby disclaims all copyright interest
  3. -- in the following source code by Joshua D. Baer (josh@starnine.com).
  4. -- 
  5. -- This source code is free and has been placed into the public domain.
  6. -- You can redistribute it, modify it (including these comments) and/or
  7. -- create derivative works from it as you see fit.
  8. --
  9. -- This source code is made available in the hope that it will be useful,
  10. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  12. -----------------------------------------------------------------------
  13.  
  14. (* UNCOMMENT FOR TESTING *)
  15. --property s9MailFileName : "test message"
  16. (* END TESTING SECTION *)
  17.  
  18. property trigger_succeeds : 1
  19. property trigger_fails : 0
  20. property trigger_error : -1
  21.  
  22. property spool_folder : ""
  23.  
  24. try
  25.     tell application "Finder"
  26.         if (exists of item spool_folder) is false then --see if stored property is valid
  27.             if exists of item ((startup disk as string) & "ListSTAR/SMTP:ListSTAR Server") then
  28.                 copy (startup disk as string) & "ListSTAR/SMTP:Message Spool/SMTP:" to spool_folder
  29.             else if exists of item ((startup disk as string) & "ListSTAR/MS:ListSTAR Server") then
  30.                 copy (startup disk as string) & "ListSTAR/MS:Message Spool/MS:" to spool_folder
  31.             else if exists of item ((startup disk as string) & "ListSTAR/POP:ListSTAR Server") then
  32.                 copy (startup disk as string) & "ListSTAR/POP:Message Spool/POP:" to spool_folder
  33.             else if exists of item ((startup disk as string) & "ListSTAR/QM:ListSTAR Server") then
  34.                 copy (startup disk as string) & "ListSTAR/QM:Message Spool/QM:" to spool_folder
  35.             else
  36.                 error "The Spool Folder could not be found." number 100
  37.             end if
  38.         end if
  39.         if (exists of file (spool_folder & s9MailFileName)) is false then --check spool file
  40.             error "There is a problem with the spool file." number 101
  41.         end if
  42.     end tell
  43.     set the_file to open for access file (spool_folder & s9MailFileName) --open file for reading
  44.     set the_line to "Start" --initialize the_line
  45.     repeat while (the first character of the_line) is not return
  46.         set the_line to read the_file until return --read in one line
  47.         ignoring case
  48.             if the_line contains "Subject:" or the_line contains "Subj:" then
  49.                 close access the_file
  50.                 -- grab the value of the subject field
  51.                 try
  52.                     set OldDelims to AppleScript's text item delimiters
  53.                     set AppleScript's text item delimiters to ":"
  54.                     set the Subject to text item 2 of the_line
  55.                     set AppleScript's text item delimiters to OldDelims
  56.                 on error errMsg number errNum
  57.                     set AppleScript's text item delimiters to OldDelims
  58.                     error errMsg number errNum
  59.                 end try
  60.                 --if it's blank
  61.                 if the_line starts with (" " & return) or the_line starts with return then
  62.                     return trigger_succeeds
  63.                     --if it's not
  64.                 else
  65.                     return trigger_fails
  66.                 end if
  67.             end if
  68.         end ignoring
  69.     end repeat
  70.     -- if we've made it this far, there was no "Subject" RFC in the message so we return 
  71.     -- trigger_succeeds indicating that the subject was not present
  72.     close access the_file
  73.     return trigger_succeeds
  74. on error errMsg number errNum
  75.     close access the_file
  76.     if errNum is not -39 then --check for end of file
  77.         display dialog (errMsg & return & errNum) buttons {"Cancel"} default button "Cancel" with icon stop
  78.         return trigger_error
  79.     else --reached end of file 
  80.         return trigger_fails
  81.     end if
  82. end try